package hnlg.com.cn.hetongmanage.control;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import hnlg.com.cn.common.RespBean;
import hnlg.com.cn.hetongmanage.service.IHetongService;
import hnlg.com.cn.model.HetongVo;
//
@RestController
@RequestMapping("/hetongControl")
public class HetongManageControl {
List<HetongVo> list=null;
RespBean rb=null;
HetongVo vo=null;
@Resource IHetongService HetongService;
//http://localhost:8044/test/hetongControl/queryhetong?jzmc=基站3&quyu_id=2&yzdh=133
@RequestMapping("/queryhetong")
public List<HetongVo> queryhetong(
	@RequestParam(required=false,defaultValue="") String jzmc,
	@RequestParam(required=false,defaultValue="") String quyu_id,
	@RequestParam(required=false,defaultValue="") String yzdh){
	try{
	   HetongVo vo=new HetongVo();
	   vo.setJzmc(jzmc);
	   if(quyu_id!=null&!quyu_id.equals("")){
	   vo.setQuyu_id(Integer.parseInt(quyu_id));}
	   vo.setYzdh(yzdh);
	   list=HetongService.queryHetong(vo);
	}catch(Exception e){
		e.printStackTrace();
	}
	return list;
}
//http://localhost:8044/test/hetongControl/addhetong?jzmc=基站2&hetong=C合同&mianji=888&dizhi=浙江绍兴&yzmc=林总&yzdh=777
@RequestMapping("/addhetong")
public RespBean addhetong(HetongVo vo){
	try {
		HetongService.addHetong(vo);
		rb=new RespBean("msg","添加成功");
	} catch (Exception e) {
		e.printStackTrace();
		rb=new RespBean("msg","添加成功");
	}
	return rb;
}
//http://localhost:8044/test/hetongControl/deletehetong?id=12
@RequestMapping("/deletehetong")
public RespBean deletehetong(@RequestParam("id") String id){
	try{
		System.out.println("id=="+id);
		HetongService.deleteHetong(id);
		rb=new RespBean("msg","删除成功");
	}catch(Exception e){
		e.printStackTrace();
		rb=new RespBean("msg","删除失败");
	}
	return rb;
}
//http://localhost:8044/test/hetongControl/updatehetong?id=8&jzmc=基站2&hetong=C合同&mianji=888&dizhi=浙江绍兴&yzmc=林总&yzdh=777
@RequestMapping("/updatehetong")
public RespBean updatehetong(HetongVo vo){
	try{
		System.out.println("vo.getId()=="+vo.getId());
		boolean flag=HetongService.updateHetong(vo);
		System.out.println("=="+flag);
		rb=new RespBean("msg","更新成功");
	}catch(Exception e){
		e.printStackTrace();
		rb=new RespBean("msg","更新失败");
	}
	return rb;
}
//http://localhost:8044/test/hetongControl/queryvo?id=3
@RequestMapping("/queryvo")
public HetongVo queryvo(String id){
	try{
		System.out.println("id=="+id);
		vo=HetongService.queryvo(id);
	}catch(Exception e){
		e.printStackTrace();
	}
	return vo;
}

}
